﻿package site1.views.modules {
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.events.Event;
	import fwk.siteManager2.DisplayElement;
	import fwk.utiles.Utiles;
	import site1.SiteApp;
	import flash.net.registerClassAlias;


	/**
	 * Classe a compiler dans deploy/shared/swf/PageElement1.swf
	 */
	public class PageElement1 extends DisplayElement
	{
		
		private var _mc:MovieClip;
		private var _xml:XML;		private var _tab:Array;
		
		public function PageElement1() 
		{
			trace("new PageElement1");
			
			// pour pouvoir être instancier par MainBase
			registerClassAlias("PageElement1", PageElement1);

		}
		override public function init():void 
		{  
			SiteApp.main.debugIt("--------> PageElement1.init()");	
			
			SiteApp.main.debugIt("page infos");
			SiteApp.main.debugIt("uipage : " + template.uipage);
			
			// instance clip template qui se trouve dans l'asset PageElement1
			_mc 		=  Utiles.getObjectFromLibrary("mcTemplate1") as MovieClip;
			addChild(_mc);
			_mc.addEventListener(Event.CLOSE, onCloseComplete);			
			// recup xml
			_xml 		= new XML( template.ressources["xml"] as String);
			
			// recup image
			var img:DisplayObject = template.ressources["img"] as DisplayObject;
			_mc.containerImage.addChild(img);
			
			
			
			_tab = new Array();
			for (var i : int = 0; i < 1000000; i++) {
				_tab.push("test");
			}
			
			//init texte
			SiteApp.main.initTextFromNode(_mc.texte, _xml.blocTexte1.texte[0]);
		}


		
		
		override public function display():void 
		{

			SiteApp.main.debugIt("--------> PageElement1.display()");	
			_mc.gotoAndPlay("display");
			
			
		}
		override public function close():void 
		{
			SiteApp.main.debugIt("--------> PageElement1.close()");	
			_mc.gotoAndPlay("close");
		}

		

		private function onCloseComplete(e:Event):void 
		{
			super.onCloseFinish();
		}
		
		
		override public function onDeepLinkChange():void 
		{
			SiteApp.main.debugIt("--------> PageElement1.onDeepLinkChange()");	
			
		}
	}
	
}